<?
    final class Principio_View_Helper_Companies extends Zend_View_Helper_Abstract
    {
        /*
        public function companies($expand = null)
        {
            $html = $this->view->messages();
            $companies = ((!is_null($expand)) && (isset($expand['company_collection']))) ? $expand['company_collection'] : $this->view->company_collection;

            foreach ($companies as $company_item)
            {
                $model_company = $company_item->getValue();

                $is_expand = (!is_null($expand)) && (isset($expand['id'])) && ($expand['id'] == $model_company->getID());

                $html .= "<li class=\"has_content\">";
                $html .= "<div class=\"node_pict ".($is_expand ? "opened" : "closed")."\" id=\"company_".$model_company->getID()."\" onClick=\"expandMenu({id: 0, controller: 'viewbycompany', company_id: ".$model_company->getID().", level: EXPAND_VIEW_BY_COMPANY_IN_COMPANY});\"></div>";
                $html .= "<a href=\"\" ".($model_company->getID() == $this->view->selected_company_id ? "class=\"active\"" : "")." onClick=\"ajaxViewByCompany({id: ".$model_company->getID().", action: 'view', use_inner: true, no_apply: true}); return false;\">".($model_company->isPool() ? "[@]" : "")."<nobr>".$model_company->getCaption()."</nobr></a>";
                $html .= "<ul id=\"company_".$model_company->getID()."_content\" ".($is_expand ? "style=\"display: block;\"" : "").">";
                if ($is_expand)
                    $html .= $expand['expand'];
                $html .= "</ul></li>";
            };

            $html .= "<li class=\"add_item\"><a href=\"\" ".($this->view->selected_company_id == -1 ? "class=\"active\"" : "")." onClick=\"addItem({menu: 'viewbycompany', container: 'inner'".((!is_null($expand)) && (isset($expand['pool_id'])) ? ", pool_id: ".$expand['pool_id'] : "")."}); return false;\">Add new company</a></li>";

            return $html;
        }
        */

        public function companies(PrincipioLab_LinkedList $collection_company, Principio_Model_Company $target_model_company = null, array $expand = null)
        {
            $html = $this->view->messages();

            foreach ($collection_company as $model_company)
            {
                //$is_expand = (!is_null($expand)) && (isset($expand['id'])) && ($expand['id'] == $model_company->getID());
                $is_expand = (!is_null($target_model_company) && ($target_model_company->getID() == $model_company->getID()));

                $html .= "<li class=\"has_content\">";
                $html .= "<div class=\"node_pict ".($is_expand ? "opened" : "closed")."\" id=\"company_".$model_company->getID()."\" onClick=\"expandMenu({id: 0, controller: 'viewbycompany', company_id: ".$model_company->getID().", level: EXPAND_VIEW_BY_COMPANY_IN_COMPANY});\"></div>";
                $html .= "<a href=\"\" ".($model_company->getID() == $this->view->selected_company_id ? "class=\"active\"" : "")." onClick=\"ajaxViewByCompany({id: ".$model_company->getID().", action: 'view', use_inner: true, no_apply: true}); return false;\">".($model_company->isPool() ? "[@]" : "")."<nobr>".$model_company->getCaption()."</nobr></a>";
                $html .= "<ul id=\"company_".$model_company->getID()."_content\" ".($is_expand ? "style=\"display: block;\"" : "").">";
                /*
                if ($is_expand)
                    $html .= $expand['expand'];
                */
                $html .= "</ul></li>";
            };

            //$html .= "<li class=\"add_item\"><a href=\"\" ".($this->view->selected_company_id == -1 ? "class=\"active\"" : "")." onClick=\"addItem({menu: 'viewbycompany', container: 'inner'".((!is_null($expand)) && (isset($expand['pool_id'])) ? ", pool_id: ".$expand['pool_id'] : "")."}); return false;\">Add new company</a></li>";
            $html .= "<li class=\"add_item\"><a href=\"\" onClick=\"addItem({menu: 'viewbycompany', container: 'inner'}); return false;\">Add new company</a></li>";

            return $html;
        }

    };
?>